package netty.test19Channelhandler;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

/**
 * 注意这里的泛型Long,因为我们上一个handler传过来的是long，所以这里直接写long就行了
 *
 */
public class MyServerHandler extends SimpleChannelInboundHandler<Long> {
    @Override
    protected void channelRead0(ChannelHandlerContext channelHandlerContext, Long aLong) throws Exception {
        System.out.println("44444444444MyServerHandler 执行了");

        System.out.println("从客户端读取到long数据："+aLong);
        channelHandlerContext.writeAndFlush(aLong);
    }

    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
        ctx.close();
    }
}
